<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>

    html{
      /* 变量需要在:root下定义 */
      --main-color:red
    }
    .box{
      color: var(--main-color)
    }
  </style>
</head>
<body>
  <div class="box">
    哈哈哈哈哈
  </div>
</body>
</html>